package com.mybatis.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mybatis.basic.entity.AjaxJson;
import com.mybatis.entity.TestUser;
import com.mybatis.service.sys.UserService;

@Controller
@RequestMapping(value = "user")
public class UserController {

	@Resource()
	private UserService userService;

	@RequestMapping(value = "/{userName}/{password}",method = RequestMethod.GET)
	@ResponseBody
	public boolean login(@PathVariable("userName")String userName,
			@PathVariable("passWord")String password){
		System.out.println(userName);
		System.out.println(password);
		if(userName.equals("nie") && password.equals("123")){
			return true;
		}
		return false;
	}

	@RequestMapping(value = "userSelect")
	@ResponseBody
	public TestUser select(){
		TestUser user = userService.select();
		System.err.println("查询成功");
		return user;
	}

	@RequestMapping(method = RequestMethod.POST)
	@ResponseBody
	public AjaxJson add(TestUser testUser){
		System.out.println(testUser+"-------------------------------------------");
		return userService.add(testUser);
	}

}
